package com.myk.game.heroscuffle.skills;

import com.myk.game.heroscuffle.game.HateRecorder;
import com.myk.game.heroscuffle.game.Hero;
import com.myk.game.heroscuffle.game.Skill;

import java.util.List;

public class Skill_LiuXing extends Skill {

    private static final int TARGET_NUM = 3; //目标数量
    private static final int DAMAGE = 90; //命中伤害值

    public Skill_LiuXing() {
        super("流星", "随机选择三名其他英雄，分别对他们造成一次伤害。", 3, Integer.MAX_VALUE);
    }

    @Override
    protected void onTrigger() {
        StringBuilder hitNames = new StringBuilder();
        int aliveCount = game.pool.getAliveCount();
        List<Hero> heroList = game.pool.getAllAliveHeroesBy(null, hostHero).subList(0, aliveCount > TARGET_NUM ? TARGET_NUM : aliveCount - 1);
        for (Hero hero : heroList) {
            hitNames.append(hero.getObviousName()).append("、");
        }
        hitNames.substring(0, hitNames.length() - 1);
        game.ui.printMsg("命中" + hitNames + heroList.size() + "名英雄，");
        game.ui.sleepShortly();
        for (Hero hero : heroList) {
            game.ui.printMsg(hero.getObviousName());
            hero.sufferDamage(null, this, null, DAMAGE);
            if (hero.state.isAlive) {
                //hero.setEnemy(hostHero);
                game.recorder.record(game.round,hostHero,hero, HateRecorder.HATE_TYPE_EFFECT);
            }
            game.ui.sleepShortly();
        }
    }

    @Override
    protected void onUpdate() {

    }

    @Override
    protected void onInit() {

    }
}
